package com.liu.redis.config;

import jodd.util.ThreadUtil;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author LIU
 * @version 1.0.0
 * @date 2025/7/22
 */
@Component
@EnableScheduling
public class RedisTest {

    @PostConstruct
    public void init() {

        System.out.println("初始化了");
        ThreadUtil.sleep(10000);
    }

    @Scheduled(cron="*/1 * * * * *")
    public void test() {
        System.out.println("定时任务执行了" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }

}
